package VectorApproach;

import java.util.ArrayList;

import XmlLoader.Position;
import Cluster.Vector;

public class Distribution {

	public Vector vecStart = null;
	ArrayList<Integer> listDistribution = null;
	double min = 9999, max = -1;
	int NoDist = -1, segID = -1;
	boolean isOne = false;
	
	double importantance = 0.0;
	
	public Distribution(Vector vecStart, int NoDist, int segID) {
		this.vecStart = vecStart;
		this.NoDist = NoDist;
		this.segID = segID;
		this.listDistribution = new ArrayList<Integer>();
	}
	
	public void ACT001_addEle(Integer value) {
		if(value > this.max) {
			this.max = value;
		}
		if(value < this.min) {
			this.min = value;
		}
		this.listDistribution.add(value);
	}
	
	public void ACT002_show() {
		int index = 0;
		System.out.print("ID " + this.NoDist + "-" + this.segID + "(" + this.vecStart.startPos.x + "," + this.vecStart.startPos.y + ") : ");
		while(index < this.listDistribution.size()) {
			System.out.print(this.listDistribution.get(index) + " * ");
			index = index + 1;
		}
		System.out.print(" /Imp : " + this.importantance);
	}
	
	public void ACT003_countImportance() {
		this.importantance = (this.max - this.min) * this.listDistribution.size();
	}
	
	public void ACT004_mergeDistribution(Distribution dist) {
		int index = 1;
		while(index < dist.listDistribution.size()) {
			this.ACT001_addEle(dist.GET001_listDistribution().get(index));
			index = index + 1;
		}
	}
	
	public ArrayList<Integer> GET001_listDistribution() {
		return this.listDistribution;
	}
	
	public int[] GET002_ID() {
		int[] result = {this.NoDist, this.segID};
		return result;
	}
	
	public double GET003_importance() {
		return this.importantance;
	}
	
	public Position GET004_left() {
		return new Position(this.vecStart.getStartPos().x, this.vecStart.getStartPos().y);
	}
	
	public Position GET005_right() {
		return new Position(this.vecStart.getStartPos().x + this.vecStart.eachVector.x * this.listDistribution.size(),
				this.vecStart.getStartPos().y + this.vecStart.eachVector.y * this.listDistribution.size());
	}
	
	public Position GET006_medium() {
		return new Position(this.vecStart.getStartPos().x + this.vecStart.eachVector.x * this.listDistribution.size()/2,
				this.vecStart.getStartPos().y + this.vecStart.eachVector.y * this.listDistribution.size()/2);
	}
	
	public boolean GET007_isOne() {
		return this.isOne;
	}
	
	public double GET008_max() {
		return this.max;
	}
	
	public Position GET009_indexToPos(int index) {
		return new Position(this.vecStart.getStartPos().x + this.vecStart.eachVector.x * index,
				this.vecStart.getStartPos().y + this.vecStart.eachVector.y * index);
	}
	
	public void SET001_isOne() {
		this.isOne = true;
	}
}
